package com.example.demo.util;

import com.alibaba.excel.EasyExcel;
import com.example.demo.pojo.DemoData;

import java.util.ArrayList;
import java.util.List;

public class TestEasyExcelWrite {

    public static void main(String[] args) {
        String filename = "D:\\桌面\\期末作业\\1.xls";

        EasyExcel.write(filename, DemoData.class).sheet("学生列表").doWrite(getData());
    }


    //创建方法返回list集合
    private static List<DemoData> getData() {
        List<DemoData> list = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            DemoData data = new DemoData();
            data.setSno(i);
            data.setName("lucy"+i);
            list.add(data);
        }
        return list;
    }

}
